package com.estar.integaration.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.estar.integaration.Util.Util;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author YJL
 * @since 2021-11-21
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
public class Material implements Serializable {

    private String id;

    /**
     * 物料编码
     */
    private String materialNo;

    /**
     * 物料名称
     */
    private String materialName;

    /**
     * 图号
     */
    private String figureNo;

    /**
     * 规格
     */
    private String specs;

    /**
     * 品牌
     */
    private String brand;

    /**
     * 单台数量
     */
    private Double quantity;

    /**
     * 计划数量
     */
    private Double planQuantity;

    /**
     * 单价
     */
    private String price;

    /**
     * 总价
     */
    private Double totalPrice;

    /**
     * bom备注
     */
    private String bomRemark;

    /**
     * 采购交期
     */
    private Date delivery;

    /**
     * 已购
     */
    private Double purchased;

    /**
     * 剩余未购
     */
    private Double unpurchased;

    /**
     * 本次要买
     */
    private Double thisPurchase;

    /**
     * 退货数量
     */
    private Double backGoods;

    /**
     * 库存
     */
    private Double inventory;

    /**
     * 存在旧单
     */
    private String existOld;

    /**
     * 审批编号
     */
    private String approvalCode;

    /**
     * 是否加急
     */
    private Boolean isUrgent;

    private String inventoryRemark;

    /**
     * 完整A码id
     */
    private String aCodeProductVo;

    /**
     * 产品id
     */
    private String productId;

    @TableField("a_code")
    private String ACode;

    //父物料号
    private String parentCode;


    public static Material cloneMVO2M(MaterialVo mvo){
        Material m = new Material();
        m.setId(Util.getUUID());
        m.setMaterialNo(mvo.getMaterialNo());
        m.setApprovalCode(mvo.getApprovalCode());
        m.setMaterialName(mvo.getMaterialName());
        m.setFigureNo(mvo.getFigureNo());
        m.setSpecs(mvo.getSpecs());
        m.setBrand(mvo.getBrand());
        m.setQuantity(mvo.getQuantity());
        m.setPlanQuantity(mvo.getPlanQuantity());
        m.setPurchased(0d);
        m.setUnpurchased(mvo.getPlanQuantity());
        m.setPrice(mvo.getPrice());
        m.setBomRemark(mvo.getBomRemark());
        m.setACodeProductVo(mvo.getFullACodeId());
        m.setInventory(0d);
        m.setDelivery(mvo.getDelivery());
        m.setIsUrgent(mvo.getIsUrgent());
        m.setInventoryRemark(mvo.getInventoryRemark());
        m.setProductId(mvo.getProductId());
        m.setACode(mvo.getACode());
        return m;
    }





}
